<?php

/**
 * Pwiff - PHP SWF Library
 *
 * LICENSE
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @package    Pwiff
 * @copyright  Copyright (c) 2010 Steven Harris
 * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @version    $Id: Movie.php 3 2010-02-08 05:22:51Z indigo.sunrise $
 */

/**
 * The Movie class represents the overall SWF file. It contains properties
 * used by the file, and the list of tags which make up the structure.
 * 
 * @package Pwiff
 */
class Pwiff_Movie
{
	/**
	 * The environment for movie generation/parsing.
	 * 
	 * @var Pwiff_Environment
	 */
	protected $environment;
	
	/**
	 * The frame width of the movie, in pixels.
	 *
	 * @var int
	 */
	protected $frameWidth;
	
	/**
	 * The frame height of the movie, in pixels.
	 * 
	 * @var int
	 */
	protected $frameHeight;
	
	/**
	 * The frame rate of the movie.
	 * 
	 * @var float
	 */
	protected $frameRate;
	
	/**
	 * List of tags that make up the movie.
	 * 
	 * @var array(Pwiff_Tag)
	 */
	protected $tags = array();
	
	/**
	 * Constructor. Accepts a Pwiff Environment instance.
	 * 
	 * @param  Pwiff_Environment $env
	 */
	public function __construct(Pwiff_Environment $env)
	{
		$this->environment = $env;
	}
	
	/**
	 * Sets the frame size, in pixels.
	 * 
	 * @param  int $width
	 * @param  int $height
	 * @return Pwiff_Movie
	 */
	public function setFrameSize($width, $height)
	{
		$this->frameWidth  = $width;
		$this->frameHeight = $height;
		return $this;
	}
	
	/**
	 * Sets the frame rate.
	 * 
	 * @param  float $rate
	 * @return Pwiff_Movie
	 */
	public function setFrameRate($rate)
	{
		$this->frameRate = $rate;
		return $this;
	}
	
	/**
	 * Adds a tag to the movie.
	 * 
	 * @param  Pwiff_Tag $tag
	 * @return Pwiff_Movie
	 */
	public function addTag(Pwiff_Tag $tag)
	{
		$this->tags[] = $tag;
	}
	
	/**
	 * Gets the associated environment.
	 * 
	 * @return Pwiff_Environment
	 */
	public function getEnvironment()
	{
		return $this->environment;
	}
	
	/**
	 * Gets the frame size in pixels, as array(width, height).
	 * 
	 * @return array
	 */
	public function getFrameSize()
	{
		return array($this->frameWidth, $this->frameHeight);
	}
	
	/**
	 * Gets the frame rate.
	 * 
	 * @return float
	 */
	public function getFrameRate()
	{
		return $this->frameRate;
	}
	
	/**
	 * Gets the frame count.
	 * TODO: Implement
	 *
	 * @return int
	 */
	public function getFrameCount()
	{
		return 0;
	}
	
	/**
	 * Gets the tag list.
	 * 
	 * @return array
	 */
	public function getTags()
	{
		return $this->tags;
	}
}
